using UnityEngine;
using System.Collections;

public class DropGenerator
{
    const float DropChance = 0.2f;
    /// <summary>
    /// Genera el drop que va a crear el enemigo dependiendo que arma tenia.
    /// </summary>
    /// <param name="weaponid"></param>
    /// <returns></returns>
    static public Item GetDrop(string weaponid, Enemy enemy)
    {
        float r = Random.RandomRange(0.0f,1.0f);
        if (r > DropChance)
        {
            return null;
        }
        else
        {
            GameObject go = PrefabManager.GetInstance().GetPrefab(weaponid + "bullet");
            if (go == null)
            {
                return null;
            }
            Bullets bulletprefab = go.GetComponent<Bullets>();
            bulletprefab.m_WeaponId = weaponid;
            Bullets todrop = ((GameObject)GameObject.Instantiate(bulletprefab.gameObject)).GetComponent<Bullets>();
            todrop.Initialize();
            todrop.ShowModelWorld(false);
            todrop.transform.position = enemy.transform.position;
            todrop.m_Holder = enemy;
            return todrop;
        }
    }
}
